package com.hwtx.form.persistence.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.hwtx.form.domain.FormConstants;
import com.hwtx.form.util.JacksonUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.Date;

@Data
@TableName("api_def")
@Schema(description = "API接口定义表")
public class ApiDef {

    @TableId(value = "id", type = IdType.AUTO)
    @Schema(description = "主键")
    private Long id;

    @Schema(description = "描述")
    private String description;

    @Schema(description = "分类")
    private String type;

    @Schema(description = "模型名")
    private String modelName;

    @Schema(description = "编码")
    private String code;

    @Schema(description = "扩展程序")
    private String ext;

    @Schema(description = "返回类型")
    private FormConstants.ApiRetType retType;

    @Schema(description = "App是否需要认证")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Integer appAuth;

    @Schema(description = "管理端是否需要认证")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Integer adminAuth;
    @Schema(description = "请求方式")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String method;

    @Schema(description = "读/写")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private int wr;

    @Schema(description = "是否批量")
    private Boolean batch;

    @Schema(description = "状态")
    private Integer status;

    @Schema(description = "参数配置")
    @JsonDeserialize(using = JacksonUtil.ListToStringDeserializer.class)
    private String params;

    @TableField(fill = FieldFill.INSERT)
    @Schema(description = "创建时间")
    @JsonIgnore
    private Date createTime;

    @Schema(description = "创建人ID")
    @JsonIgnore
    @TableField(fill = FieldFill.INSERT)
    private String createId;

    @TableField(fill = FieldFill.INSERT_UPDATE)
    @Schema(description = "修改时间")
    @JsonIgnore
    private Date updateTime;

    @Schema(description = "更新人ID")
    @JsonIgnore
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private String updateId;

}
